import request from '@/utils/request';

interface BrandItem {
  bannerId: string;
  bannerName: string;
  picUrl: string;
  createDate: string;
}

interface ListResponse {
  list: BrandItem[];
  total: number;
}

export async function qryBrandListPage(params: {
  pageIndex?: number;
  pageSize?: number;
  param?: {
    bannerName?: string;
  };
}): Promise<ListResponse> {
  const response = await request('/brand/qryBrandListPage', {
    method: 'POST',
    data: params,
  });
  return {
    list: response.data || [],
    total: response.total || 0,
  };
}

export async function addBrand(params: {
  bannerName: string;
  picUrl: string;
}): Promise<void> {
  await request('/brand/addBrand', {
    method: 'POST',
    data: params,
  });
}

export async function updateBrand(params: {
  bannerId: string;
  bannerName: string;
  picUrl: string;
}): Promise<void> {
  await request('/brand/updateBrand', {
    method: 'POST',
    data: params,
  });
}

export async function deleteBrand(params: { bannerId: string }): Promise<void> {
  await request('/brand/deleteBrand', {
    method: 'POST',
    data: params,
  });
}

export async function qryBrandDetail(params: {
  bannerId: string;
}): Promise<BrandItem> {
  const response = await request('/brand/qryBrandDetail', {
    method: 'POST',
    data: params,
  });
  return response.data;
}
